#include <iostream>
#include <QtWidgets/QApplication>
#include <QtGui/QtGui>
#include <QtOpenGLWidgets/QtOpenGLWidgets>

#include <QtWidgets/QGraphicsView>

#include "openglscene.h"


class GraphicsView : public QGraphicsView
{
public:
    GraphicsView()
    {
        setWindowTitle(tr("3D Model Viewer"));
        setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); //added
    }

protected:
    void resizeEvent(QResizeEvent *event) override
    {
        if (scene())
            scene()->setSceneRect(QRect(QPoint(0, 0), event->size()));
        QGraphicsView::resizeEvent(event);
    }
};

constexpr int WIDTH = 1024;
constexpr int HEIGHT = 768;

int main(int argc, char **argv)
{
    //QQuaternion q= QQuaternion::fromEulerAngles(0,60,0);
    //QMatrix4x4 id;
    //id.rotate(q);
    //std::for_each( id.data(), id.data() + 16, [](const float& num) {std::cout << num<<"\n";});
    
    QApplication app(argc, argv);
    GraphicsView view;
    view.setViewport(new QOpenGLWidget());
    view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);

    view.setScene(new OpenGLScene());
    view.show();    
    view.resize(WIDTH, HEIGHT);
    view.move(10, 10);
    return app.exec();
}
